<template>
    <div>
        <el-card shadow="always" :body-style="{ padding: '20px' }">
            <el-form :inline="true" class="demo-form-inline">
                <el-form-item label="一级分类">
                    <el-select placeholder="请输入" v-model="categoryStore.C1Id" @change="c1Handler" :disabled="scene!=0">
                        <el-option v-for="(c1,index) in categoryStore.C1List" :label="c1.name" :value="c1.id" />
                    </el-select>
                </el-form-item>
                <el-form-item label="二级分类">
                    <el-select placeholder="请输入" v-model="categoryStore.C2Id" @change="c2Handler" :disabled="scene!=0">
                        <el-option v-for="(c2,index) in categoryStore.C2List" :label="c2.name" :value="c2.id" />
                    </el-select>
                </el-form-item>
                <el-form-item label="三级分类">
                    <el-select placeholder="请输入" v-model="categoryStore.C3Id" @change="c3Handler" :disabled="scene!=0">
                        <el-option v-for="(c3,index) in categoryStore.C3List" :label="c3.name" :value="c3.id" />
                    </el-select>
                </el-form-item>
            </el-form>
        </el-card>



    </div>
</template>

<script setup lang="ts">
import useCategoryStore from '@/stores/category';
import useAttrStore from '@/stores/attr';
import { onMounted } from 'vue';
// 获取仓库
let categoryStore = useCategoryStore()
let attrStore = useAttrStore()
// 组件挂载
onMounted(() => {
    // 通知仓库发请求 获取一级分类的数据
    categoryStore.getC1List()
})
// 获取二级分类的数据
const c1Handler = () => {
    categoryStore.getC2List()
}

// 获取三级分类的数据
const c2Handler = () => {
    categoryStore.getC3List()
}

const c3Handler = () => {
    attrStore.getAttrList()
}

defineProps(['scene'])
</script>

<style scoped>

</style>